import { post,get } from './request';

import type {
  businessAnalysisRes,
  salesDrendRes,
  hotSellingProductsRes,
  paymentMethodRankingRes,
  popularCategoriesRes,
  createEmployeeAccountType,
  employeeListRes,
  employeeListType,
  queryItemOrderRes,
  queryOrderRes,
  queryOrderType,
  createOrderType,
  uploadCategoryType,
  editProductType,
  getGoodsType,
  getGoodsRes,
  getCategoryType,
  filterProductsType,
  captchaType,
  loginType,
  loginRes,
  sendCodeType,
  codeLoginType,
  navigationListRes,
  allcateGoryType,
  pictureSetRes,
  addGoodsType
} from '@/types/index';
export const captchaApi = (params: captchaType) => {
  return post<any[]>("/login/tencentcaptcha", params);
};
// 手机号和密码登录
export const loginApi = (params: loginType) => {
  return post<loginRes>("/login/userlogin", params);
};

// 发送验证码
export const sendCodeApi = (params: sendCodeType) => {
  return get<any[]>("/login/sendcode", params);
};
// 手机号和验证码登录
export const codeLoginApi = (params: codeLoginType) => {
  return post<loginRes>("/login/codelogin", params);
};
//导航栏
export const navigationListApi = () => {
  return get<navigationListRes[]>("/navigetion/navigation-list");
};
// 获取所有商品分类
export const allcateGoryApi = () => {
  return get<allcateGoryType[]>("/goods/allcategory");
};
export const pictureSetApi = (params: { page: number | string }) => {
  return get<pictureSetRes[]>("/file/pictureset", params);
};
// 发布商品
export const addGoodsApi = (params: addGoodsType) => {
  return post<pictureSetRes[]>("/goods/addgoods", params);
};
//获取tab筛选商品结果
export const getFilterProductsApi = () => {
  return get<filterProductsType[]>("/goods/getfilterproducts");
};
//获取所有商品分类和分类下数量
export const getCategoryApi = () => {
  return get<getCategoryType[]>("/goods/getcategory");
};
// 筛选商品数据返回结果
export const getGoodsApi = (params: getGoodsType) => {
  return get<{ res: getGoodsRes[]; total: number }>("/goods/getgoods", params);
};
// 下架商品
export const offlineProductsApi = (params: { goodsid: string }) => {
  return get<any[]>("/goods/handle-offline-products", params);
};
//上架商品
export const onlineProductsApi = (params: { goodsid: string }) => {
  return get<any[]>("/goods/handle-online-products", params);
};
// 删除商品
export const deleteProductsApi = (params: { goodsid: string }) => {
  return get<any[]>("/goods/delete-products", params);
};
// 编辑修改商品
export const editProductApi = (params: editProductType) => {
  return post<any[]>("/goods/edit-product", params);
};
// 上传分类
export const uploadCategoryApi = (params: uploadCategoryType) => {
  return post<any[]>("/file/uploadcategory", params);
};
// 堂食点餐页面请求所有商品分类
export const orderForCategoryApi = () => {
  return get<allcateGoryType[]>("/goods/order-for-category");
};
// 堂食点餐页面请求所有商品数据
export const orderForProductApi = (params?: { categoryid: string; page: string | number }) => {
  return get<{ res: getGoodsRes[]; total: number }>("/goods/order-for-product", params);
};

// 堂食点餐页面提交订单
export const createOrderApi = (params: createOrderType) => {
  return post<any[]>("/order/create-order", params);
};
// 订单页面查询订单数据
export const queryOrderApi = (params?: queryOrderType) => {
  return post<{ res: queryOrderRes[]; total: number }>("/order/query-order", params);
};
// 订单页面查询单个订单详情
export const queryItemOrderApi = (params: { goods_id: string }) => {
  return get<queryItemOrderRes[]>("/order/query-item-order", params);
};
// 查询员工数据列表
export const employeeListApi = (params?: employeeListType) => {
  return post<{ res: employeeListRes[]; total: number }>("/userinfo/employee-list", params);
};
// 拉黑员工账号
export const blockUserAccountApi = (params: { userId: string }) => {
  return get<any[]>("/userinfo/block-user-account", params);
};
// 移除黑名单
export const unblockUserApi = (params: { userId: string }) => {
  return get<any[]>("/userinfo/unblock-user", params);
};
// 获取员工职位数据
export const employeeRoleApi = () => {
  return get<{ name: string; type: string }[]>("/userinfo/employee-role");
};
// 获取员工性别
export const employeeGenderApi = () => {
  return get<{ name: string; type: string }[]>("/userinfo/employee-gender");
};
// 员工婚姻状况
export const maritalStatusApi = () => {
  return get<{ name: string; type: string }[]>("/userinfo/marital-status");
};
//#endregion
// 创建员工账号
export const createEmployeeAccountApi = (params: createEmployeeAccountType) => {
  return post<any[]>("/userinfo/create-employee-account", params);
}
// 经营概况
export const businessAnalysisApi = () => {
  return get<businessAnalysisRes[]>("/data/business-analysis");
};
// 销售额趋势
export const salesDrendApi = (params?: { queryTime: number[] }) => {
  return post<salesDrendRes>("/data/sales-drend", params);
};
// 热销商品排名
export const hotSellingProductsApi = () => {
  return get<hotSellingProductsRes[]>("/data/hot-selling-products");
};
// 支付渠道排名
export const paymentMethodRankingApi = () => {
  return get<paymentMethodRankingRes>("/data/payment-method-ranking");
};
// 热门商品分类
export const popularCategoriesApi = () => {
  return get<popularCategoriesRes[]>("/data/popular-categories");
};
